fix: 启动任务失败时更详细的日志 - #340
Conversation
先前部分分支直接return false导致快捷键处理兜底,web区只打印快捷键启动任务失败,造成误解
# Conflicts: # src/components/Toolbar.tsx
|
冲突了,康康 |
# Conflicts: # src/components/Toolbar.tsx
|
@sourcery-ai reivew |
|
Sure! I'm generating a new review now. |
There was a problem hiding this comment.
嘿——我发现了 1 个问题
给 AI Agent 的提示
请处理这次代码审查中的评论:
## 个别评论
### 评论 1
<location path="src/components/Toolbar.tsx" line_range="1312" />
<code_context>
if (!primaryResult.allDone || primaryResult.stopped) {
- log.warn(`实例 ${targetInstance.name}: 前段任务未正常结束,跳过收尾特殊任务`);
- return false;
+ const message = t('taskList.autoConnect.primaryTasksIncomplete');
+ log.warn(`实例 ${targetInstance.name}: ${message}`);
+ addLog(targetId, { type: 'warning', message });
+ onPhaseChange?.('idle');
+ return true;
}
const trailingTaskIds = await runTaskBatch(trailing, false, '收尾', true);
</code_context>
<issue_to_address>
**问题 (bug_risk):** 当主要批次停止或失败时,该函数会记录警告,但返回 `true`,因此快捷键调用方会记录 `hotkeyStartSuccess`,而计划任务调用方会将此次运行视为已成功启动,尽管主要任务并未正常完成,且收尾任务也被跳过。
**触发条件:** 任务列表包含收尾任务,并且 `waitForTasks` 报告 `allDone === false` 或 `stopped === true` 时。
**建议修复:** 对于未成功完成的主要批次返回 `false`,同时保留特定的 `primaryTasksIncomplete` 日志,以便调用方不会发出成功结果。
```suggestion
return false;
```
</issue_to_address>Original comment in English
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/components/Toolbar.tsx" line_range="1312" />
<code_context>
if (!primaryResult.allDone || primaryResult.stopped) {
- log.warn(`实例 ${targetInstance.name}: 前段任务未正常结束,跳过收尾特殊任务`);
- return false;
+ const message = t('taskList.autoConnect.primaryTasksIncomplete');
+ log.warn(`实例 ${targetInstance.name}: ${message}`);
+ addLog(targetId, { type: 'warning', message });
+ onPhaseChange?.('idle');
+ return true;
}
const trailingTaskIds = await runTaskBatch(trailing, false, '收尾', true);
</code_context>
<issue_to_address>
**issue (bug_risk):** When the primary batch stops or fails, the function logs a warning but returns `true`, so hotkey callers record `hotkeyStartSuccess` and scheduled callers treat the run as successfully started even though the primary tasks did not finish normally and the trailing tasks were skipped.
**Triggers:** When a task list has trailing tasks and `waitForTasks` reports `allDone === false` or `stopped === true`.
**Suggested fix:** Return `false` for an unsuccessful primary batch, while preserving the specific `primaryTasksIncomplete` log so callers do not emit a success result.
```suggestion
return false;
```
</issue_to_address>| log.warn(`实例 ${targetInstance.name}: ${message}`); | ||
| addLog(targetId, { type: 'warning', message }); | ||
| onPhaseChange?.('idle'); | ||
| return true; |
There was a problem hiding this comment.
问题 (bug_risk): 当主要批次停止或失败时,该函数会记录警告,但返回 true,因此快捷键调用方会记录 hotkeyStartSuccess,而计划任务调用方会将此次运行视为已成功启动,尽管主要任务并未正常完成,且收尾任务也被跳过。
触发条件: 任务列表包含收尾任务,并且 waitForTasks 报告 allDone === false 或 stopped === true 时。
建议修复: 对于未成功完成的主要批次返回 false,同时保留特定的 primaryTasksIncomplete 日志,以便调用方不会发出成功结果。
| return true; | |
| return false; |
Original comment in English
issue (bug_risk): When the primary batch stops or fails, the function logs a warning but returns true, so hotkey callers record hotkeyStartSuccess and scheduled callers treat the run as successfully started even though the primary tasks did not finish normally and the trailing tasks were skipped.
Triggers: When a task list has trailing tasks and waitForTasks reports allDone === false or stopped === true.
Suggested fix: Return false for an unsuccessful primary batch, while preserving the specific primaryTasksIncomplete log so callers do not emit a success result.
| return true; | |
| return false; |
|
Hey @HarcoChen, I've posted a new review for you! |
WebUI在启动任务失败时仅会报“未能通过快捷键开始任务”,即使对于开机自启动或是参数启动也是如此,容易引起疑惑。
细化了WebUI的启动失败报错,以形如“任务启动失败:具体原因”的形式打印
Sourcery 总结
通过在所有启动方式中显示具体失败原因,改进任务启动失败报告。
错误修复:
增强功能:
杂项:
Original summary in English
Sourcery 摘要
为任务启动失败提供跨启动方式一致且具体的本地化错误信息。
错误修复:
改进:
维护:
Original summary in English
Sourcery 总结
在所有启动方式中,当任务无法启动时,显示本地化且具体的原因。
Bug 修复:
增强功能:
维护工作:
Original summary in English
Summary by Sourcery
Show a localized, specific reason whenever task startup cannot proceed across all launch methods.
Bug Fixes:
Enhancements:
Chores:
Original summary in English
Original summary in English